﻿Public Class frmDepartement

    Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
        ClearText()
        Me.txtDepID.Text = AutoID4Access("SELECT  DeptID FROM tbl_departments", "tbl_departments") + 1

    End Sub
    Sub ClearText()
        Me.txtDepID.Text = ""
        Me.txtDeptDescription.Text = ""
        Me.txtNote.Text = ""
        Me.txtDepID.Text = AutoID4Access("SELECT  DeptID FROM tbl_departments", "tbl_departments") + 1
        Me.txtDeptDescription.Focus()
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Dim SQL As String = "INSERT INTO tbl_departments(DeptID,DepartmentName,[Note])" & _
                           "VALUES (" & Me.txtDepID.Text & ",'" & Me.txtDeptDescription.Text & "','" & Me.txtNote.Text & "')"

        SaveDataToAccess(SQL)
        ClearText()
        LoadDataToLVUsers("SELECT * FROM tbl_departments ", Me.LVDepartement)
    End Sub

    Private Sub ToolStrip2_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ToolStrip2.ItemClicked

    End Sub

    Private Sub frmDepartement_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Connect()
        LoadDataToLVDept("SELECT * FROM tbl_departments ", Me.LVDepartement)

    End Sub

    Private Sub TSBFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TSBFind.Click
        '   Dim ID As Integer
        '    ID = TSFind.Text
        If Me.txtDepID.Text <> "" Then
            LoadData2DeptText("SELECT * FROM tbl_departments WHERE DeptID=" & Me.TSBFind.Text, Me)
            '     LoadDataToLVUsers("SELECT * FROM tbl_users WHERE  KFullName=LIKE %'" & txtFind.Text & "'% ", Me.LVUsers)
        End If
    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click

    End Sub

    Private Sub LVDepartement_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LVDepartement.SelectedIndexChanged

    End Sub
End Class